﻿/*
 * KLF Headless Browser
 * Written by Kris Oye <kristianoye@gmail.com>
 * Copyright (C) 2011-2012.  All rights reserved.
 */
namespace KLF.Lib.Browser.Resources
{
    #region Using Statements

    using KLF.Lib.Browser.DOM;
    using KLF.Lib.Browser.DOM.HTML;
    using KLF.Lib.Browser.DOM.Parser;
    using KLF.Lib.Browser.DOM.Interface;

    #endregion

    public class IFrameRequest : ResourceRequest
    {
        public IFrameRequest(string path, ILoadableContent target)
            : base(path, target)
        {
            AssignValue = new AssignResource(LoadFrame);
        }

        public void LoadFrame(ILoadableContent receiver, string source)
        {
            HTMLIFrameElement frame = receiver as HTMLIFrameElement;

            if (frame != null)
            {
                frame._contentDocument = DocumentBuilder.Parse(source);
                frame.HasLoaded = true;
            }
        }
    }
}
